<!--
 * @Author: zqx me_zqx@163.com
 * @Date: 2025-07-11 20:01:53
 * @LastEditors: zqx me_zqx@163.com
 * @LastEditTime: 2025-09-15 10:59:04
 * @FilePath: /XMate-h5/src/views/minutes/components/labelOverview/index.vue
 * @Description: 
 * 
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved. 
-->
<template>
  <div
    class="p-4 bg-white flex flex-col justify-between items-center flex-auto min-h-[400px]"
  >
    <UnLabelView v-if="!isLabelAllParticipant" @goToLabel="handleGoToLabel" />
    <SpeechOverviewTable
      v-if="isLabelAllParticipant"
      :speechOverviewDatas="speechOverviewDatas"
    />
    <Empty
      des="生成失败"
      v-if="generateStatus === GenerateStatus.FAIL && isLabelAllParticipant"
    />
    <div class="mt-4 w-full max-w-[400px]" v-if="enableGenerate">
      <van-button
        :disabled="!isLabelAllParticipant || false"
        size="large"
        color="#436BFF"
        type="primary"
        @click="handleGenerate"
        >{{ isGenerateFail ? "重新生成" : "开始生成" }}</van-button
      >
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed, ComputedRef } from "vue";
import { useMinutesStore } from "@/store";
import { GenerateStatus } from "@/types";
import Empty from "@/components/emptyView.vue";
import SpeechOverviewTable from "./SpeechOverviewTable.vue";
import UnLabelView from "./unLabelView.vue";
import EventBus from "@/EventBus.js";
import { EventBusEnum } from "@/types";

const store = useMinutesStore();

const speechOverviewDatas = computed(() => store.speechOverviewData);

// FAIL
const generateStatus: ComputedRef<GenerateStatus> = computed(
  () => store.generateReportState.generateStatus
);

const isGenerateFail = computed(() => generateStatus.value === GenerateStatus.FAIL);

const handleGenerate = () => {
  store.generateReportAction();
};

const isOwner = computed(() => store.isOwner);
const isLabelAllParticipant = computed(() => store.isLabelAllParticipant);

const enableGenerate = computed(() => {
  return isLabelAllParticipant.value && isOwner.value;
});

const handleGoToLabel = () => {
  EventBus.emit(EventBusEnum.CHANGE_TAB_MAIN, 0);
};
</script>

<style scoped lang="less">
.van-button {
  width: 100%;
  height: 40px;
}
</style>
